var currentPage=1;
 var id = getvl("id");
 var currentPage=1;
 $(function(){
 	   if(id!=null){
 	   	  selectGoodsList2();
 	   }else{
 	   	alert("登录异常...");
 	   }
 });
 var ss=0;
function  selectGoodsList2(){ 
	
	 if(currentPage==1 || ss!=0){
		$.ajax({
             url: urlcore + "/api/order/WXselect?current="+currentPage+"&userId="+id+"&status=5&types=1",
            type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
						ss=data.data.length;
					$.each(data.data,function(y,n) {
						  var zhuantai="";
						 if(n.status==8){
						    	zhuantai="退款申请中";
						    }else if(n.status==9){
						    	zhuantai="退款失败 ";
						    }else if(n.status==10){
						    	zhuantai="退款成功";
						    }
						
			var quanbuleirong=
			'<div class="detail_goods clearfix">'+
						'<h4>'+n.shop.storeName+'<span>'+zhuantai+'</span></h4>';
    	                if(n.goodsCarList!=null){
	          $.each(n.goodsCarList, function(k,m) {
	          	 quanbuleirong+='<div class="clearfix tuwen">';
	          	 if(n.status==8){
	          	quanbuleirong+='<a href="12.9.1buy_dingdan_tuikuan_detail.html?id='+n.id+'">';
	          	 }else{
	          	 	quanbuleirong+='<a href="12.9.3buy_dingdan_tuikuan_wancheng_detail.html?id='+n.id+'">';
	          		
	          	 }
                     
    	                quanbuleirong+='<div class="tuwen-img fl">'+
	          	 '<img onerror="errorImg2(this)" src="'+m.goods.coverUrl+'" width="75" height="75">'+
	        '</div>'+
	        '<div class="tuwen-wenzi">'+
	            '<h5 class="wuye_h01">'+m.goods.goodsTitle+'</h5>'+
	         /*   '<div class="wuye_div01">'+m.goodsSimple+'</div>'+*/
	        '</div>'+
        '</a>'+
    '</div>';
              if(m.myStockList!=null){
    	  $.each(m.myStockList, function(q,w) {
           	   quanbuleirong+='<div class="dingdan_fenlei clearfix">'+
    	  '<ul class="fl">';
    		if(w.colour!=null){
    quanbuleirong+='<li>颜色：<span>'+w.colour.colourName+'</span></li>';
    		}
    		
    		if(w.size!=null){
    quanbuleirong+='<li>尺码：<span>'+w.size.sizeName+'</span></li>';			
    		}
    		if(m.packPrice!=null){
    quanbuleirong+='<li>单价：<span>'+m.packPrice+'元/件</span></li>';
    		}
    		
    quanbuleirong+='</ul>'+
    	'<div class="fr">';
    	   
    	      if(n.goodsNumber>=m.tradeNumber){
    	      	quanbuleirong+='<h5>'+m.goods.tradePrice+'元</h5>'+
    		'<h6>'+n.goodsNumber+'件</h6>';
    	      }else{
    	     quanbuleirong+='<h5>'+m.goods.packPrice+'元</h5>'+
    		'<h6>'+n.goodsNumber+'件</h6>';
    	      }
    	quanbuleirong+='</div>'+
              '</div>';
           });
          }
           
             });
            }
            if(n.status==8){
			 quanbuleirong+='<div class="dingdan_footer">'+
    	'<div class="fr">'+
    		'<span class="dingdan_quxiao" onclick="bianhaos('+n.orderNumber+')">取消退款</span>'+
    	'</div>'+
    '</div>'+
'</div>';
						    }else if(n.status==9){
				quanbuleirong+='<div class="dingdan_footer">'+
				'<div class="fr">'+
    		'<span class="dingdan_shanchu" onclick="bianhaos('+n.orderNumber+')">删除</span>'+
    	'</div>'+
    '</div>'+
'</div>';		    	
						    }else if(n.status==10){
				quanbuleirong+='<div class="dingdan_footer">'+
				'<div class="fr">'+
    		'<span class="dingdan_shanchu" onclick="bianhaos('+n.orderNumber+')">删除</span>'+
    	'</div>'+
    '</div>'+
'</div>';		    	
						    }
						$("#quanbuleirong").append(quanbuleirong);
						
			});
			
			      $(function(){
			      	 // 取消订单
    // 弹出
    $(".dingdan_quxiao").on('click',function(){
        $("body").append("<div id='mask'></div>");
        $(".show-quxiao").show();
    })
    //点击关闭
    $(".Quxiao").on('click',function(){
        $(".show-quxiao").hide();
        $("#mask").remove();
    }) 
    
    //提醒发货
    $('.dingdan_tixing').on('click',function(){		
		$(this).html("已提醒").css("background","#f5f5f5");
	});	
    
    
    //确认收货
    // 弹出
    $(".dingdan_queren").on('click',function(){
        $("body").append("<div id='mask'></div>");
        $(".show-queren").show();
    })
    //点击关闭
    $(".Quxiao").on('click',function(){
        $(".show-queren").hide();
        $("#mask").remove();
    }) 
    
    
    //删除
    // 弹出
    $(".dingdan_shanchu").on('click',function(){
        $("body").append("<div id='mask'></div>");
        $(".show-shanchu").show();
    })
    //点击关闭
    $(".Quxiao").on('click',function(){
        $(".show-shanchu").hide();
        $("#mask").remove();
    }) 
			      });
			
					
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		}
	}
	
//取消订单

function bianhaos(te){
	$("#biaohaos").val("");
	$("#biaohaos").val(te);
}

function  querenquxiao(){
	 var biaohaos=$("#biaohaos").val();  
	 if(biaohaos==''){
	 	
	 }else{
   	  $.ajax({
      url: urlcore+"/api/order/cancelOrder?orderNumber="+biaohaos,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
				   alert("已取消");
				}
			},
			error: function() {
				alert("error");
			}
		});
}
}


function shanchu(){
	
	 var biaohaos=$("#biaohaos").val();  
	 if(biaohaos==''){
	 	
	 }else{
   	  $.ajax({
      url: urlcore+"/api/order/cancelOrder?orderNumber="+biaohaos+"&types=3",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
				   selectGoodsList2();
				}
			},
			error: function() {
				alert("error");
			}
		});
}

}

